﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AsterNET.FastAGI.Command;

namespace AsterNET.Extensions.FastAGI.Helpers
{

    public enum VoicemailFolders
    {
        INBOX = 0,
        Old = 1,
        Work = 2,
        Family = 3,
        Friends = 4,
        Cust1 = 5,
        Cust2 = 6,
        Cust3 = 7,
        Cust4 = 8,
        Cust5 = 9
    }

    public class VoicemailMainOptions
    {
        /// <summary>
        /// Consider the mailbox parameter as a prefix to the mailbox that is entered by the caller.
        /// </summary>
        /// <returns></returns>
        public static string Prefix()
        {
            return "p";
        }

        /// <summary>
        ///  Use the specified amount of gain when recording a voicemail message. The units are whole-number decibels (dB).
        /// </summary>
        /// <param name="gain"></param>
        /// <returns></returns>
        public static string Gain(int gain)
        {
            return string.Format("g({0})", gain.ToString());
        }

        /// <summary>
        /// Skip checking the passcode for the mailbox.
        /// </summary>
        /// <returns></returns>
        public static string SkipPasswordCheck()
        {
            return "s";
        }

        /// <summary>
        /// Auto play new messages in the given folder
        /// </summary>
        /// <param name="folder"></param>
        /// <returns></returns>
        public static string AutoPlay(VoicemailFolders folder)
        {
            return string.Format("a({0})", ((int)folder).ToString());
        }
    }


    public class VoicemailMainHelper
    {
        /// <summary>
        /// Enters the main voicemail system for the checking of voicemail. The mailbox can be passed as the option, which will stop the voicemail system from prompting the user for the mailbox.
        /// </summary>
        /// <returns></returns>
        public static ExecCommand VoicemailMain()
        {
            return VoicemailMain(null);
        }

        /// <summary>
        /// Enters the main voicemail system for the checking of voicemail. The mailbox can be passed as the option, which will stop the voicemail system from prompting the user for the mailbox.
        /// </summary>
        /// <param name="mailbox"></param>
        /// <returns></returns>
        public static ExecCommand VoicemailMain(string mailbox)
        {
            return VoicemailMain(mailbox, null, new string[] { });
        }

        /// <summary>
        /// Enters the main voicemail system for the checking of voicemail. The mailbox can be passed as the option, which will stop the voicemail system from prompting the user for the mailbox.
        /// </summary>
        /// <param name="mailbox"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public static ExecCommand VoicemailMain(string mailbox, string context)
        {
            return VoicemailMain(mailbox, context, new string[] {});
        }

        /// <summary>
        /// Enters the main voicemail system for the checking of voicemail. The mailbox can be passed as the option, which will stop the voicemail system from prompting the user for the mailbox.
        /// </summary>
        /// <param name="mailbox"></param>
        /// <param name="context"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public static ExecCommand VoicemailMain(string mailbox, string context, params string[] options)
        {
            var opts = string.Join(",", options);
            return new ExecCommand("VoicemailMain", opts);
        }

    }
}
